/*
2018-08-14
@lane
@thamiti@163.com

*/
const pre_name = 'app_';
export default {
    set: function (k, v) {
        if (typeof v == 'object') {
            if(v == null) {
                v = ""
            }else{
                v = JSON.stringify(v);
            }
            
        } else if (typeof v == 'number') {
            v = v + "";
        } else if (typeof v == 'boolean') {
            v = v + "";
        } else if (typeof v == 'undefined') {
            alert("数据值-->undefined")
        }
        window.localStorage.setItem(pre_name + k,v)
    },
    get: function (k) {
        var str = window.localStorage.getItem(pre_name + k);
        try{
            str = JSON.parse(str);
            return str
        }catch(e){
            console.log(e)
            return str
        }
    }
}
